import request from "@/utils/request";
import type { ResultList, BaseInfo } from '@/@types/index.type'

export interface DictType extends BaseInfo {
  id?: number
  name: string
  dictType: string
}

export interface DictData extends BaseInfo {
  id?: number
  label?: string
  value?: string
  dictType?: string
  listClass?: string
}

// 保存字典
export const saveDictData = (data: any) => request.post('system/dict/data', data)
// 获取字典数据
export const getDictDataList = (params: any) => request.get<ResultList<DictData>>('system/dict/data', params)
// 获取字典数据详情
export const getDictData = (id: number) => request.get<DictData>('system/dict/data/' + id)
// 删除字典数据
export const deleteDictData = (id: number) => request.delete('system/dict/data/' + id)
// 修改字典数据
export const updateDictData = (id: number, data: any) => request.put('system/dict/data/' + id, data)
// 通过标识获取字典数据
export const getDictListByDictType = (dictType: string) => request.get<DictData[]>('system/dict/data/key/' + dictType)

// 获取字典类型列表
export const getDictTypeList = (params: any) => request.get<ResultList<DictType>>('system/dict/type', params)
// 保存字典类型
export const saveDictType = (data: DictType) => request.post('system/dict/type', data)
// 删除字典类型
export const deleteDictType = (id: number) => request.delete('system/dict/type/' + id)
// 获取字典类型详情
export const getDictType = (id: number) => request.get <DictType>('system/dict/type/' + id)
// 修改字典类型
export const updateDictType = (id: number, data: any) => request.put('system/dict/type/' + id, data)